package project.taobao.microsoft.transaction.provider.one;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @author yhq
 * @date 2020/8/26 10:27
 */
@SpringBootApplication(scanBasePackages = {"project.taobao.microsoft.transaction.provider.one.controller",
        "project.taobao.microsoft.transaction.provider.one.service",
        "project.taobao.microsoft.transaction.provider.one.config"})
@MapperScan("project.taobao.microsoft.transaction.provider.one.dao")
@EnableEurekaClient
// 开启熔断
@EnableCircuitBreaker
@EnableDiscoveryClient
public class TransacationProviderOneApplication {
    // methods
    public static void main(String[] args) {
        SpringApplication.run(TransacationProviderOneApplication.class, args);
    }

    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registration.addUrlMappings("/hystrix.stream");
        return registration;
    }
    // getters, setters

    // constructors
}
